package com.untrance.shop.common.utils;

import com.untrance.shop.common.exceptions.EmptyArrayException;
import com.untrance.shop.common.exceptions.EmptyCollectionException;

import java.util.Collection;

/**
 * @author eugene zadyra
 */
public class ValidateUtils {
    public static <T> void notNull(T object, String message){
        if(object == null){
            throw new NullPointerException(message);
        }
    }

    public static <T> void isEmpty(Collection object, String message){
        if(object.size() == 0){
            throw new EmptyCollectionException(message);
        }
    }

    public static <T> void isEmpty(T[] object, String message){
        if(object.length == 0){
            throw new EmptyArrayException(message);
        }
    }
}
